package com.saishi.servlet;

import com.saishi.dao.ExamDao;
import com.saishi.dao.impl.ExamDaoImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/dtsz/*")
public class DaTiszServlet extends BaseServlet {

    protected void gosjbx(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String xxpx = request.getParameter("xxpx");
        String csxz = request.getParameter("csxz");
        String dxxz = request.getParameter("dxxz");
        String dasz = request.getParameter("dasz");HttpSession session = request.getSession();
        int id = Integer.parseInt(session.getAttribute("examid").toString());
//        int id =1;


//        session.setAttribute("szxxpx",xxpx);
//        session.setAttribute("szcsxz",csxz);
//        session.setAttribute("szdxxz",dxxz);
//        session.setAttribute("szdasz",dasz);
        ExamDao examDao = new ExamDaoImpl();
        try {
            int ok = examDao.updasz(xxpx,csxz,dxxz,dasz,id);
            System.out.println("修改是否成功："+ok);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        response.sendRedirect("<%=request.getScheme() + \"://\" + request.getServerName() + \":\" + request.getServerPort() + request.getContextPath() + \"/\"%>sjbx/seletm");
    }


    protected void goksjbxx1 (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        String xxpx = request.getParameter("xxpx");
        String csxz = request.getParameter("csxz");
        String dxxz = request.getParameter("dxxz");
        String dasz = request.getParameter("dasz");
        int id = Integer.parseInt(session.getAttribute("examid").toString());
//        int id =1;

//        session.setAttribute("szxxpx",xxpx);
//        session.setAttribute("szcsxz",csxz);
//        session.setAttribute("szdxxz",dxxz);
//        session.setAttribute("szdasz",dasz);
        ExamDao examDao = new ExamDaoImpl();
        try {
            int ok = examDao.updasz(xxpx,csxz,dxxz,dasz,id);
            System.out.println("修改是否成功："+ok);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        response.sendRedirect("<%=request.getScheme() + \"://\" + request.getServerName() + \":\" + request.getServerPort() + request.getContextPath() + \"/\"%>ksjbxx.jsp");
    }
}
